package fag.editor;

import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JPanel;

import fag.core.model.Frame;

public class AnimationPanel extends JPanel {

	private static final long serialVersionUID = -4893279018887695636L;
	private Frame frame;
	private double posCenterX;
	private double posCenterY;
	
	AnimationPanel() {
		
		setSize(400,400);
		frame = null;
		updateCenter(400,400);
		
	}
	
	public void setFrame(Frame f) {
		
		frame = f;
	}
	
	public void updateCenter(int w,int h) {
		
		posCenterX = w / 2;
		posCenterY = h / 2;
		repaint();
	}
	
	public void paintComponent(Graphics g) {

		if(frame != null) {
			
			if(frame.getBufferedImage() != null) {
							
							g.drawImage(frame.getBufferedImage(),
										(int)(posCenterX+(frame.getOffSet().x)),
										(int)(posCenterY+(frame.getOffSet().y)),
										frame.getBufferedImage().getWidth(),
										frame.getBufferedImage().getHeight(),
										null);
						}
		}
	}
}
	
